<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.eso.frame.AppConstant" %>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>LeftFrame</title>
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'frame.css')}" type="text/css">
    <r:external dir="js" file="project.js"/>

    <script type="text/javascript">
        var preClassName = "";
        function list_sub_detail(Id, item) {
            if (preClassName != "") {
                getObject(preClassName).className = "left_back"
            }
            if (getObject(Id).className == "left_back") {
                getObject(Id).className = "left_back_onclick";
                outlookbar.getbyitem(item);
                preClassName = Id
            }
        }

        function outlook() {
            this.titleList = new Array();
            this.itemList = new Array();
            this.addtitle = addtitle;
            this.additem = additem;
            this.getLeftMenu = getLeftMenu;
            this.getbyitem = getbyitem;
            this.getDefaultExpandMenu = getDefaultExpandMenu;
        }

        function theitem(intitle, insort, inkey, inisdefault) {
            this.sortname = insort;
            this.key = inkey;
            this.title = intitle;
            this.isdefault = inisdefault
        }
        function addtitle(intitle, sortname, inisdefault) {
            outlookbar.itemList[outlookbar.titleList.length] = new Array();
            outlookbar.titleList[outlookbar.titleList.length] = new theitem(intitle, sortname, 0, inisdefault);
            return(outlookbar.titleList.length - 1)
        }
        function additem(intitle, parentid, inkey) {
            if (parentid >= 0 && parentid <= outlookbar.titleList.length) {
                insort = "item_" + parentid;
                outlookbar.itemList[parentid][outlookbar.itemList[parentid].length] = new theitem(intitle, insort, inkey, 0);
                return(outlookbar.itemList[parentid].length - 1)
            }
            else additem = -1
        }

        /**
         * 加载指定模块左侧“默认展开”二级菜单
         * @param moduleName 功能模块名称
         */
        function getDefaultExpandMenu(moduleName) {
            var output = "";
            //是否存在默认展开的菜单：当功能模块下存在多个默认展开菜单时，不标记具体哪个被选中，否则标记默认展开的菜单为“已点击过”
            var isExistDefaultMenu = 0;
            for (var i = 0; i < outlookbar.titleList.length; i++) {
                if (outlookbar.titleList[i].isdefault == 1 && outlookbar.titleList[i].sortname == moduleName) {
                    //alert("isDefault:"+outlookbar.titleList[i].isdefault+",title:"+outlookbar.titleList[i].title)
                    output += "<div class=list_tilte id=sub_sort_" + i + " onclick=\"exchangeMenu('sub_detail_" + i + "')\">";
                    output += "<span>" + outlookbar.titleList[i].title + "</span>";
                    output += "</div>";
                    output += "<div class=list_detail id=sub_detail_" + i + "><ul>";
                    for (var j = 0; j < outlookbar.itemList[i].length; j++) {
                        output += "<li id=" + outlookbar.itemList[i][j].sortname + j + " onclick=\"loadMainFrame('" + outlookbar.itemList[i][j].title + "', '" + outlookbar.titleList[i].title + "', '" + outlookbar.itemList[i][j].key + "')\">";
                        output += "<a href='#'>"+outlookbar.itemList[i][j].title + "</a></li>";
                    }
                    output += "</ul></div>"
                }
            }
            getObject('right_main_nav').innerHTML = output
        }

        /**
         * 加载指定模块左侧一级菜单
         * @param moduleName 模块名称
         */
        function getLeftMenu(moduleName) {
            var output = "<ul>";
            for (var i = 0; i < outlookbar.titleList.length; i++) {
                if (outlookbar.titleList[i].sortname == moduleName) {
                    output += "<li id=left_nav_" + i + " onclick=\"list_sub_detail(id, '" + outlookbar.titleList[i].title + "')\" class=left_back>" + outlookbar.titleList[i].title + "</li>"
                }
            }
            output += "</ul>";
            getObject('left_main_nav').innerHTML = output
        }
        function getbyitem(item) {
            var output = "";
            for (i = 0; i < outlookbar.titleList.length; i++) {
                if (outlookbar.titleList[i].title == item) {
                    output = "<div class=list_tilte id=sub_sort_" + i + " onclick=\"exchangeMenu('sub_detail_" + i + "')\">";
                    output += "<span>" + outlookbar.titleList[i].title + "</span>";
                    output += "</div>";
                    output += "<div class=list_detail id=sub_detail_" + i + " style='display:block;'><ul>";
                    for (j = 0; j < outlookbar.itemList[i].length; j++) {
                        output += "<li id=" + outlookbar.itemList[i][j].sortname + "_" + j + " onclick=\"loadMainFrame('" + outlookbar.itemList[i][j].title + "', '" + outlookbar.titleList[i].title + "', '" + outlookbar.itemList[i][j].key + "')\">";
                        output += "<a href='#'>"+outlookbar.itemList[i][j].title + "</a></li>";
                    }
                    output += "</ul></div>"
                }
            }
            getObject('right_main_nav').innerHTML = output
        }

        /**
         * 点击二级子菜单，右侧中间区域根据URL加载页面内容，并修改内容导航栏标题
         * @param menuName 菜单名称
         * @param moduleName 模块名称
         * @param targetURL 菜单URL
         */
        function loadMainFrame(menuName, moduleName, targetURL) {
            if (menuName != "" && moduleName != "") {
                if(targetURL.indexOf('logout') < 0)
                    window.top.frames['navBar'].getObject('show_text').innerHTML = moduleName + "  <img src=${request.contextPath}/images/frame/slide.gif broder=0 />  " + menuName;
            }
            if (targetURL != "") {
                var goURL = "${request.contextPath}/"+targetURL;
                if(targetURL.indexOf('logout')>0 && confirm("您确定要退出当前系统吗？")){//退出
                    window.parent.location = goURL;
                } else {
                    window.top.frames['main'].location = goURL;
                }
            }
        }

        /**
         * 菜单间的切换
         * @param divId 菜单显示区域ID
         */
        function exchangeMenu(divId) {
            var subSortId = "sub_sort_" + divId.substring(11);
            if (getObject(divId).style.display == "none") {
                getObject(divId).style.display = "block";
                getObject(subSortId).className = "list_tilte";
            }
            else {
                getObject(divId).style.display = "none";
                getObject(subSortId).className = "list_tilte_onclick"
            }
        }

        /**
         * 系统登录后加载指定默认模块的左侧菜单
         * @param moduleName 模块名称
         */
        function initDefaultExpandMenu(moduleName) {
            outlookbar.getLeftMenu(moduleName);
            outlookbar.getDefaultExpandMenu(moduleName);
        }
        document.write("<script src=${request.contextPath}/js/nav.js></" + "script>");

        //退出
        function logout(){
            if(confirm("您确定要退出当前系统吗？"))
                window.parent.location = "${request.contextPath}/auth/logout";
        }
    </script>

</head>
<body onload="initDefaultExpandMenu('管理首页')">
<div id="left_content">
    <div id="user_info">
        欢迎您，<strong>${session[AppConstant.SESSION.USER]?.userName}</strong><br/>
        [<a href="#"><span style="color: red;font-weight: bold;">10</span>条未读信息</a>，<a href="javascript:logout();">退出</a>]
    </div>

    <div id="main_nav">
        <div id="left_main_nav"></div>

        <div id="right_main_nav"></div>
    </div>
</div>
</body>
</html>
